package servlet.admin;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import pojo.User2;
import service.UserLoginService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/admindeleteuser")
public class DeleteUser extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        UserLoginService userLoginService = new UserLoginService();
        long l = Long.parseLong(id);
        int i = userLoginService.deleteUserAdmin(l);
        resp.setContentType("application/json;charset=utf-8");
        JSONObject jsonResponse = new JSONObject();
        jsonResponse.put("code", 1); // 添加books列表
        String jsonString2 = jsonResponse.toJSONString();
        PrintWriter writer = resp.getWriter();
        writer.write(jsonString2);
    }
}
